<!DOCTYPE html>
<html class="no-js css-menubar" lang="en">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
  <meta name="description" content="bootstrap admin template">
  <meta name="author" content="">
  <script type="text/javascript" src="../_resource/js/header.js"></script>
  <script>
    var RUN_FUNCS = [];
	var SITE_URL  = "http://admin.html.me";
	var CURR_CONTROLLER  = "FaqCategory";
	var CURR_ACTION  = "add";
    Breakpoints();
  </script>
  <style type="text/css">
    .list-table table td, .list-table table th{background:#fff; text-align:center;}
    .__access{display: none;}
  </style>
  </head>
<body class="dashboard">
  <!--[if lt IE 8]>
  <p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
  <![endif]-->

  <nav class="site-navbar navbar navbar-default navbar-fixed-top navbar-mega" role="navigation" id="navbardefaultmodel">
       <script type="text/javascript" src="../_resource/js/include.js" onload="HM.SomeFun('head_html')"></script>
  </nav>
  <div class="site-menubar">
    <div class="site-menubar-body" id="site-menubar-body">
        <script type="text/javascript" src="../_resource/js/include.js" onload="HM.SomeFun('nav_html')"></script>
    </div>
  </div>

  <!-- Page -->
  <div class="page">
    <div class="page-content container-fluid">
          
<div class="panel form-box " style="">
    <div class="panel-body">
        <form class="validate-form ajax-form" id="bossjobForm" method="post" enctype="application/x-www-form-urlencoded" target="_self" autocomplete="off">
            <div class="row row-lg">
                <div class="col-lg-6 form-horizontal">
                    <div id="category_name-form-item"  class="form-group " style="" >
                        <label for="category_name" class="control-label ">
                            Category Name:<span class="required">*</span>             
                        </label>
                        <div>
                            <input type="text" name="category_name" id="category_name" class="form-control " style="" placeholder=""  value="" />
                            <input type="text" name="id" id="category_id" value="" style="display: none;">
                            <span style="float: left;width: 100%;height: 20px;line-height: 20px;color:red;" id="category_name_error"></span>
                        </div>
                    </div>
                    <div id="status-form-item"  class="form-group " style="" >
                        <label for="status" class="control-label ">Status:</label>
                        <div>
                            <select class="form-control form-control-sm" name="category_status" id="category_status">
                                <option value="1" >Activate</option>
                                <option value="2" >Deactivate</option>
                            </select>
                        </div>
                    </div>
                </div>
                <div style="display: none;" class="col-lg-6 form-horizontal">
                    <div id="parent_id-form-item"  class="form-group " style="" >
                        <label for="parent_id" class="control-label ">Parent Category:</label>
                        <div>
                            <select class="form-control form-control-sm" name="parent_id" id="parent_id">
                            <option value="0">Please select</option>
                            </select>
                        </div>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <button type="button" id="save-faq-category" class="btn btn-lg btn-success">Submit</button>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript">
$(function(){
    var _get = Api.Params()['id'];
    Api.Get('getFaqCateDetail', Api.Params()['id'], function(object, error){
        if(object['message'] == 'OK' && object['status_code'] == 200){
            if(object['data']){
                var category = object['data'][0];
                $('#category_id').val(category['id']);
                $('#category_name').val(category['category_name']);
                $('#category_status option[value="'+category['category_status']+'"]').attr('selected', 'selected');
            }
        }else{
            $.showError('Something Error, Retry Please.', 300, function(obj){
                window.location.href = '/FaqCategory/index.html';
            });
        }
    });
    $('#save-faq-category').click(function(){
        var cateName = $('#category_name').val().trim();
        if(0 == cateName.length){
            $('#category_name_error').html('category name can not be empty.');
            return false;
        }
        $('#category_name_error').html('');
        var cateStatus = $('#category_status').val();
        var parentId = $('#parent_id').val();
        var postData = {
            'id' : parseInt($('#category_id').val()),
            'category_name' : cateName,
            'parent_id' : parentId,
            'category_status' : cateStatus
        };
        Api.Put('saveFaqCate', postData, function(object, error){
            if(object['message'] == 'OK' && object['status_code'] == 200){
                $.showSuccess('Save FAQ Category Successfully!', 300, function(obj){
                    window.location.href = '/FaqCategory/index.html';
                });
            }else{
                console.log(object);
                $.showError('Something Error, Retry Please.', 300, function(obj){
                    window.location.reload();
                });
                return true;
            }
        });
    });
});
</script>
    </div>
	
	<!-- Modal -->
	<div class="modal fade" id="confirmModal" aria-hidden="true" role="dialog" tabindex="-1">
	  <div class="modal-dialog modal-center">
		<div class="modal-content">
		  <div class="modal-header">
			<h4 class="modal-title"></h4>
		  </div>
		  <div class="modal-body">
			<p></p>
		  </div>
		  <div class="modal-footer">
			<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
			<button type="button" class="btn btn-primary"></button>
		  </div>
		</div>
	  </div>
	</div>
	<div class="modal fade" id="alertModal" aria-hidden="true" role="dialog" tabindex="-1">
	  <div class="modal-dialog modal-center">
		<div class="modal-content">
		  <div class="modal-header">
			<button type="button" class="close" data-dismiss="modal" aria-label="Close">
				<span aria-hidden="true">×</span>
            </button>
			<h4 class="modal-title"></h4>
		  </div>
		  <div class="modal-body">
			<p></p>
		  </div>
		</div>
	  </div>
	</div>
	<!-- End Modal -->
  </div>
  <!-- End Page -->

  <!-- Footer -->
  <script type="text/javascript" src="../_resource/js/footer.js"></script>

    <script>
    (function(document, window, $) {
      'use strict';

      var Site = window.Site;
      $(document).ready(function() {
        Site.run();
          $('textarea[maxlength]').maxlength({
              threshold: 1000,
              placement: 'bottom-left-inside'
          });

          $.components.register("datepicker",{mode:"default",defaults:{autoclose:!0}});

        if (RUN_FUNCS.length > 0) {
          for(var i = 0; i < RUN_FUNCS.length; i++) {
            RUN_FUNCS[i].call();
          }
        }
      });
    })(document, window, jQuery);


  </script>
</body>
</html>